<!DOCTYPE html>
<html>
<head>
    <title>可选BPM列表</title>
    <%include("/app/resapi/mobilestyle.html"){}%>
</head>
<body>
<section class="g-flexview">
    <section class="g-scrollview">
        <div class="m-cell" id="J_ListContent">
        </div>
    </section>

</section>

<script id="J_ListHtml" type="text/html">
    {{each list as data}}
    <a href="/mobile/bpm/bpmbegin?flowId={{data.flowId}}&&flowName={{data.flowName}}" class="cell-item">
        <div class="cell-left">{{data.flowName}}</div>
        <div class="cell-right cell-arrow"></div>
    </a>
    {{/each}}
</script>
<%include("/app/resapi/mobilejs.html"){}%>
<script src="/module/art-template/template-web.js"></script>
<script>
    var page = 1;
    $(function () {
        bindData();
    });

    function bindData() {
        var loadMore = function (callback) {
            $.ajax({
                url: '/ret/bpmget/getMobileMyBpmFlowList?&page=' + page,
                type: "post",
                dataType: "json",
                success: function (data) {
                    var ret = data.list;
                    if (ret) {
                        // 该示例使用了arttemplate模板引擎，当然你也可以用其他方式
                        $('#J_ListContent').prepend(template('J_ListHtml', {
                            list: ret
                        }));
                        var tipStr = ret.length > 0 ? '为您更新了' + ret.length + '条内容' : '已是最新内容';
                        ++page;
                        YDUI.dialog.toast(tipStr, 'none', 1500);
                    }
                },
                complete: function () {
                    typeof callback == 'function' && callback();
                }
            });
        };
        $('#J_ListContent').pullRefresh({
            loadListFn: function () {
                var def = $.Deferred();
                loadMore(function () {
                    def.resolve();
                });
                return def.promise();
            }
        });

    }
</script>
</body>
</html>
